SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vwDesignacionDiaria
AS
SELECT DISTINCT 
                      dbo.tb_Vacantes.idVacante, dbo.tb_Plazas.CUPOF, dbo.tb_Agentes.Nombres, dbo.tb_Agentes.Documento, 
                      dbo.vwrTiposDeDocumento.Descripcion AS TipoDeDocumento, dbo.tb_Vacantes.PuntajeDesignacion, dbo.tb_Vacantes.OrdenDesignacion, 
                      dbo.vwrTurnos.Descripcion AS Turno, dbo.vwrSuborganizaciones.Nivel, dbo.vwrSuborganizaciones.Categoria, dbo.vwrSuborganizaciones.Zona, 
                      dbo.vwrLocalidades.Descripcion AS Localidad, dbo.vwrConcursos.Descripcion AS Concurso, SUBSTRING(dbo.vwrCargosGenericos.Descripcion, 9, 40) 
                      AS CargoGenerico, dbo.vwrConcursos.Convocatoria, dbo.vwrOrganizacionesSF.Nombre AS Organizacion, dbo.vwrDivisiones.Curso, 
                      dbo.vwrDivisiones.Division, dbo.vwrSituacionRevista.Descripcion AS SitRevistaDesignado, dbo.tb_Vacantes.FechaBaja, 
                      dbo.tb_Vacantes.FechaDesignacion
FROM         dbo.vwrTiposDeDocumento INNER JOIN
                      dbo.tb_Agentes ON dbo.vwrTiposDeDocumento.ID = dbo.tb_Agentes.TipoDocumento LEFT OUTER JOIN
                      dbo.vwrSituacionRevista LEFT OUTER JOIN
                      dbo.vwrTurnos RIGHT OUTER JOIN
                      dbo.vwrOrganizacionesSF RIGHT OUTER JOIN
                      dbo.vwrDivisiones RIGHT OUTER JOIN
                      dbo.vwrConcursos INNER JOIN
                      dbo.tb_Plazas INNER JOIN
                      dbo.tb_Vacantes ON dbo.tb_Plazas.idPlaza = dbo.tb_Vacantes.Plaza ON dbo.vwrConcursos.id = dbo.tb_Vacantes.Concurso LEFT OUTER JOIN
                      dbo.vwrLocalidades ON dbo.tb_Vacantes.Localidad = dbo.vwrLocalidades.ID ON dbo.vwrDivisiones.ID = dbo.tb_Plazas.Division ON 
                      dbo.vwrOrganizacionesSF.ID = dbo.tb_Plazas.Organizacion ON dbo.vwrTurnos.ID = dbo.tb_Plazas.Turno LEFT OUTER JOIN
                      dbo.vwrSuborganizaciones ON dbo.tb_Plazas.SubOrganizacion = dbo.vwrSuborganizaciones.ID ON 
                      dbo.vwrSituacionRevista.ID = dbo.tb_Vacantes.SitRevDesignado ON dbo.tb_Agentes.idAgente = dbo.tb_Vacantes.AgenteDesignado FULL OUTER JOIN
                      dbo.vwrCargosGenericos RIGHT OUTER JOIN
                      dbo.tb_TraslacionDeCYA ON dbo.vwrCargosGenericos.ID = dbo.tb_TraslacionDeCYA.CargoGenerico ON 
                      dbo.tb_Plazas.CargoSalarialDefault = dbo.tb_TraslacionDeCYA.Cargo AND dbo.tb_Plazas.Asignatura = dbo.tb_TraslacionDeCYA.Asignatura
GO
GRANT SELECT ON  [dbo].[vwDesignacionDiaria] TO [CentroDeDesignaciones]
GRANT SELECT ON  [dbo].[vwDesignacionDiaria] TO [SoloVer]
GO
EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[63] 4[13] 2[6] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1[50] 2[25] 3) )"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1 [56] 4 [18] 2))"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "vwrTiposDeDocumento"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 84
               Right = 227
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_Agentes"
            Begin Extent = 
               Top = 6
               Left = 265
               Bottom = 114
               Right = 466
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrSituacionRevista"
            Begin Extent = 
               Top = 84
               Left = 38
               Bottom = 177
               Right = 227
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrTurnos"
            Begin Extent = 
               Top = 114
               Left = 265
               Bottom = 207
               Right = 454
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrOrganizacionesSF"
            Begin Extent = 
               Top = 180
               Left = 38
               Bottom = 288
               Right = 227
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrDivisiones"
            Begin Extent = 
               Top = 210
               Left = 265
               Bottom = 318
               Right = 454
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrConcursos"
            Begin Extent = 
               Top = 288
               Left = 38
               Bottom = 396
               Right = 227
', 'USER', N'dbo', 'VIEW', N'vwDesignacionDiaria', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_DiagramPane2', N'            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_Plazas"
            Begin Extent = 
               Top = 396
               Left = 38
               Bottom = 504
               Right = 268
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_Vacantes"
            Begin Extent = 
               Top = 504
               Left = 38
               Bottom = 888
               Right = 241
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrLocalidades"
            Begin Extent = 
               Top = 504
               Left = 279
               Bottom = 597
               Right = 468
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrSuborganizaciones"
            Begin Extent = 
               Top = 605
               Left = 640
               Bottom = 713
               Right = 829
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrCargosGenericos"
            Begin Extent = 
               Top = 612
               Left = 38
               Bottom = 720
               Right = 227
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_TraslacionDeCYA"
            Begin Extent = 
               Top = 731
               Left = 446
               Bottom = 839
               Right = 635
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      RowHeights = 220
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'USER', N'dbo', 'VIEW', N'vwDesignacionDiaria', NULL, NULL
GO
DECLARE @xp int
SELECT @xp=2
EXEC sp_addextendedproperty N'MS_DiagramPaneCount', @xp, 'USER', N'dbo', 'VIEW', N'vwDesignacionDiaria', NULL, NULL
GO
